class UserType < ActiveRecord::Base
  has_and_belongs_to_many :advertisments
#  has_and_belongs_to_many :categories
  has_many :user_type_category_maps
  has_many :categories              , :conditions => ["relation_type = ?" , 0] , :through => :user_type_category_maps
  has_many :categories_for_posting  , :conditions => ["relation_type = ?" , 1], :source => :category , :through => :user_type_category_maps
  
  def advertisments_by_university(university)
    self.advertisments.find(:all,:conditions => ["university_id = ?",university.id])
  end
end
